<html>
<head>
<title>BIServer Groovy Console</title>

	<script src="lib/codemirror/js/codemirror.js" type="text/javascript"></script>
<!--<link rel="stylesheet" type="text/css" href="lib/codemirror/css/docs.css" />-->
	<link rel="stylesheet" href="lib/jquery/css/base/jquery.ui.all.css"> 
	<script src="lib/jquery/js/jquery-1.4.2.min.js" type="text/javascript"></script> 
	<script src="lib/jquery/js/jquery-ui-1.8.6.custom.min.js" type="text/javascript"></script> 
	<script src="lib/jquery/js/jquery.url.js" type="text/javascript"></script> 
	<script src="js/main.js" type="text/javascript"></script>     

<link rel="stylesheet" href="lib/blueprintcss/screen.css" type="text/css"
	media="screen, projection">
<link rel="stylesheet" href="lib/blueprintcss/print.css" type="text/css"
	media="print">
<!--[if lt IE 8]><link rel="stylesheet" href="css/blueprint/ie.css" type="text/css" media="screen, projection"><![endif]-->

<style type="text/css">
.CodeMirror-line-numbers {
	width: 2.2em;
	color: #aaa;
	background-color: #eee;
	text-align: right;
	padding-right: .3em;
	font-size: 10pt;
	font-family: monospace;
	padding-top: .4em;
	line-height: normal;
}

</style>


</head>

<body>

<div class="container">
<div class="span-24 last"><span>filename</span></div>
<div class="span-4"><!-- Left sidebar --></div>

<div class="span-16">

	<div id="editor-container" style="border: 1px solid black; border-color: #aaa">
		<textarea id="code" name="script"	cols="140" rows="40"></textarea>
	</div>

	<div>
	<button id="execute" type="submit" class="button">Execute</button>
	<button id="save" type="submit" class="button">Save</button>
	<button id="save-as" type="submit" class="button">Save As</button>
	</div>
	
</div>

<div class="span-4 last">

        <div id="tabs"> 
            <ul> 
            	<li><a href="#tabs-result">Result</a></li> 
            	<li><a href="#tabs-output">Output</a></li> 
            	<li><a href="#tabs-error">Error</a></li> 
            </ul> 
            
            <div id="tabs-result"> 
                <pre id="result" class="border hidden"></pre> 
            </div> 
        
            <div id="tabs-output"> 
                <pre id="output" class="border hidden"></pre> 
            </div> 
        
            <div id="tabs-error"> 
                <pre id="error" class="border hidden"></pre> 
            </div> 
        </div> 
</div>
<div class="span-24 last"><!-- Footer --></div>
</div>

<script language="javascript"> 

            var editor = CodeMirror.fromTextArea('code', {
                height: "300px",
                parserfile: ["tokenizegroovy.js", "parsegroovy.js"],
                stylesheet: "lib/codemirror/css/groovycolors.css",
                path: "lib/codemirror/js/",
                continuousScanning: 500,
                lineNumbers: true,
                textWrapping: false,
                tabMode: "spaces",
                submitFunction: function() {
                    jQuery("#executeButton").click();
                }
            });
 
            var scriptId = $.url.param("id")
            if (null != scriptId) {
                $.get(
                        "/pentaho/plugin/cws/api/repo/files/"+scriptId+"/data/text",
                        function(data) {
                           editor.setCode(data);
                        }, 'html'
                );
            }

        </script>

</body>
</html>
